First law of thermodynamics for change of state